﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using CommonLibrary.DB;
using CommonLibrary.DataModel.WorkFlow;
using System.Data;
using ServiceApplication.Dao.Basic;
using CommonLibrary.Common;

namespace ServiceApplication.Dao.WorkFlow
{
    public class TaskDao
    {
        /// <summary>
        /// 添加一条数据
        /// </summary>
        public static string Add(WfTaskEntity model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into wf_task(");
            strSql.Append("ptask_id,uniqueid,taskname,state,processresult,processtype,processaddition,user_id,fqrcode,starttime,checkintime,endtime,days,task_clyj)");
            strSql.Append(" values (");
            strSql.Append("@ptask_id,@uniqueid,@taskname,@state,@processresult,@processtype,@processaddition,@user_id,@fqrcode,@starttime,@checkintime,@endtime,@days,@task_clyj);select @@identity  ");
            SqlParameter[] parameters = {
                    new SqlParameter("@ptask_id",model.ptask_id),
					new SqlParameter("@uniqueid", model.uniqueid),
					new SqlParameter("@taskname", model.taskname),
					new SqlParameter("@state", model.state),
					new SqlParameter("@processresult",model.processresult ),
					new SqlParameter("@processtype", model.processtype),
					new SqlParameter("@processaddition",model.processaddition ),
					new SqlParameter("@user_id", model.user_id),
					new SqlParameter("@fqrcode",model.fqrcode ),
					new SqlParameter("@starttime",model.starttime ),
					new SqlParameter("@checkintime",model.checkintime ),
					new SqlParameter("@endtime",model.endtime ),
					new SqlParameter("@days", model.days),
					new SqlParameter("@task_clyj", model.task_clyj)};

            return DBExecuteUtil.getUniqueResult(strSql.ToString(), parameters);
        }
        /// <summary>
        /// 添加多条数据
        /// </summary>
        public static void Add(List<WfTaskEntity> modelList)
        {
            StringBuilder strSql;
            foreach (WfTaskEntity item in modelList)
            {
                strSql = new StringBuilder();
                strSql.Append("insert into wf_task(");
                strSql.Append("ptask_id,uniqueid,taskname,state,processresult,processtype,processaddition,user_id,fqrcode,starttime,checkintime,endtime,days,task_clyj)");
                strSql.Append(" values (");
                strSql.Append("@ptask_id,@uniqueid,@taskname,@state,@processresult,@processtype,@processaddition,@user_id,@fqrcode,@starttime,@checkintime,@endtime,@days,@task_clyj);select @@identity  ");
                SqlParameter[] parameters = {
                    new SqlParameter("@ptask_id",item.ptask_id),
					new SqlParameter("@uniqueid", item.uniqueid),
					new SqlParameter("@taskname", item.taskname),
					new SqlParameter("@state", item.state),
					new SqlParameter("@processresult",item.processresult ),
					new SqlParameter("@processtype", item.processtype),
					new SqlParameter("@processaddition",item.processaddition ),
					new SqlParameter("@user_id", item.user_id),
					new SqlParameter("@fqrcode",item.fqrcode ),
					new SqlParameter("@starttime",item.starttime ),
					new SqlParameter("@checkintime",item.checkintime ),
					new SqlParameter("@endtime",item.endtime ),
					new SqlParameter("@days", item.days),
					new SqlParameter("@task_clyj", item.task_clyj)};
                DBExecuteUtil.getUniqueResult(strSql.ToString(), parameters);
            }
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static void Update(WfTaskEntity model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update wf_task set ");
            strSql.Append("state=@state,");
            strSql.Append("processresult=@processresult,");
            strSql.Append("processaddition=@processaddition,");
            strSql.Append("checkintime=@checkintime");
            strSql.Append(" where task_id=@task_id ");
            List<SqlParameter> parameters = new List<SqlParameter>(){
                    new SqlParameter("@uniqueid",model.uniqueid),
					new SqlParameter("@task_id", model.task_id),
					new SqlParameter("@state", model.state),
					new SqlParameter("@processresult", model.processresult),
					new SqlParameter("@processaddition",model.processaddition ),
					new SqlParameter("@checkintime",model.checkintime )};
            DBExecuteUtil.executeSqlWithPar(strSql.ToString(), parameters.ToArray());
        }
        /// <summary>
        /// 更新正在执行的任务状态
        /// </summary>
        /// <param name="taskid">正在执行的任务id</param>
        /// <param name="ptaskid">正在执行的父任务id</param>
        /// <param name="guid">全局唯一标识</param>
        public static void Update(string taskid, string ptaskid, Guid guid, string processresult, string task_clyj, string task_clsj, string str_id)
        {
            string sql = "update wf_task set state='废弃',endtime=@task_clsj,isread=1 " +
                "where uniqueid=@uniqueid and ptask_id=@ptask_id and task_id!=@task_id;" +
                "update wf_task set state='已处理',processresult=@processresult,task_clyj=@task_clyj,endtime=@task_clsj,isread=1,task_str=@str_id " +
                "where uniqueid=@uniqueid and ptask_id=@ptask_id and task_id=@task_id ";

            SqlParameter[] sqlParams = new SqlParameter[]{
                new SqlParameter("@uniqueid",guid),
                new SqlParameter("@ptask_id",ptaskid),
                new SqlParameter("@task_id",taskid),
                new SqlParameter("@processresult",processresult),
                new SqlParameter("@task_clyj",task_clyj),
                new SqlParameter("@task_clsj",task_clsj),
                new SqlParameter("@str_id",str_id)
            };
            DBExecuteUtil.executeSqlWithPar(sql.ToString(), sqlParams);
        }

        /// <summary>
        /// 查询数据
        /// </summary>
        /// <param name="task_id"></param>
        /// <returns></returns>
        public static WfTaskEntity Query(string task_id)
        {

            WfTaskEntity wfTaskEntity = null;
            List<SqlParameter> parameterList = new List<SqlParameter>();
            parameterList.Add(new SqlParameter("@task_id", task_id));
            string sql = "select task_id,uniqueid,taskname,state,processresult,processtype,processaddition,user_id,fqrcode,starttime,checkintime,endtime,days,ptask_id,task_clyj" +
                " from wf_task where task_id=@task_id";

            var result = DBExecuteUtil.querySqlArray(sql, parameterList.ToArray());
            if (null == result) return null;

            wfTaskEntity = new WfTaskEntity();
            wfTaskEntity.task_id = int.Parse(result[0][0]);
            wfTaskEntity.uniqueid = new Guid(result[0][1]);
            wfTaskEntity.taskname = result[0][2];
            wfTaskEntity.state = result[0][3];
            wfTaskEntity.processresult = result[0][4];
            wfTaskEntity.processtype = result[0][5];
            wfTaskEntity.processaddition = result[0][6];
            wfTaskEntity.user_id = int.Parse(result[0][7]);
            wfTaskEntity.fqrcode = int.Parse(result[0][8]);
            wfTaskEntity.starttime = result[0][9];
            wfTaskEntity.checkintime = result[0][10];
            wfTaskEntity.endtime = result[0][11];
            wfTaskEntity.days = int.Parse(result[0][12]);
            wfTaskEntity.ptask_id = int.Parse(result[0][13]);
            wfTaskEntity.task_clyj = result[0][14];
            return wfTaskEntity;
        }

        /// <summary>
        ///  根据任务状态查询用户任务,传入null或空则默认不作为参数条件传入sql查询语句
        /// </summary>
        /// <param name="user_id">用户id</param>
        /// <param name="state">任务状态</param>
        /// <returns></returns>
        public static DataTable QueryTask(string user_id, string state)
        {
            List<SqlParameter> parameterList = new List<SqlParameter>();

            string sql = "select task.task_id 任务编码,task.ptask_id 父级编码,task.uniqueid 实例标识,ins.insname 流程名称,  " +
                            " task.taskname 任务名称,task.state 任务状态,task.processresult 任务结果,starttime 开始时间,endtime 完成时间, " +
                            " task.fqrcode 发起人编码,users.user_name 发起人,depts.dept_name 部门,dutys.duty_name 职位,ins.ins_descn 备注  " +
                            " from wf_task task,jc_user users,wf_ins ins,jc_staff staffs,jc_dept depts,jc_duty dutys " +
                            " where task.fqrcode=users.user_id and task.uniqueid=ins.uniqueid  and users.staff_id=staffs.staff_id and staffs.dept_id=depts.dept_id and staffs.duty_id=dutys.duty_id and  ins.result!='废弃' ";

            if (!string.IsNullOrEmpty(user_id))
            {
                parameterList.Add(new SqlParameter("@user_id", user_id));
                sql += "  and task.user_id=@user_id  ";
            }
            if (!string.IsNullOrEmpty(state))
            {
                parameterList.Add(new SqlParameter("@state", state));
                sql += " and task.state=@state ";
            }
            sql += " order by starttime desc ";
            DataTable dt = DBExecuteUtil.querySqlTable(sql, parameterList.ToArray());

            return dt;
        }

        public static DataTable QueryTaskByLoginid(string loginid, string state)
        {
            List<SqlParameter> parameterList = new List<SqlParameter>();

            string sql = "select task.task_id 任务编码,task.ptask_id 父级编码,task.uniqueid 实例标识,task.taskname 任务名称,task.state 任务状态,starttime 开始时间,endtime 完成时间,users.user_name 发起人" +
                              " from wf_task task,jc_user users " +
                              " where task.user_id=users.user_id  ";
            if (!string.IsNullOrEmpty(loginid))
            {
                parameterList.Add(new SqlParameter("@loginid", loginid));
                sql += "  and users.user_loginid=@loginid  ";
            }
            if (!string.IsNullOrEmpty(state))
            {
                parameterList.Add(new SqlParameter("@state", state));
                sql += " and task.state=@state ";
            }
            sql += " order by starttime desc ";
            DataTable dt = DBExecuteUtil.querySqlTable(sql, parameterList.ToArray());

            return dt;
        }

        public static DataTable QueryTaskByCondition(String user_id, String applyer, String wfname, String stime, String etime, String state)
        {
            string sql = " select task.task_id 任务编码,task.ptask_id 父级编码,task.uniqueid 实例标识,ins.insname 流程名称, " +
                             " task.taskname 任务名称,task.state 任务状态,task.processresult 任务结果,starttime 开始时间, " +
                             " endtime 完成时间,task.user_id 处理人编码,u1.user_name 处理人,task.fqrcode 发起人编码,u2.user_name 发起人,ins.ins_descn 备注 " +
                             " from wf_task task,wf_ins ins,jc_user u1,jc_user u2 " +
                             " where task.user_id=u1.user_id and task.fqrcode=u2.user_id and task.uniqueid=ins.uniqueid and ins.result !='废弃'   ";

            List<SqlParameter> parameterList = new List<SqlParameter>();
            //if (uniqueids != null && uniqueids.Length > 0)
            //{
            //    sql += "  and task.uniqueid in (";
            //    for (int i = 0; i < uniqueids.Length; i++)
            //    {
            //        sql += "'" + uniqueids[i] + "',";
            //    }
            //    sql = sql.Substring(0, sql.Length - 1);//去除最后一个逗号
            //    sql += ") ";
            //}
            if (!string.IsNullOrEmpty(user_id))
            {
                parameterList.Add(new SqlParameter("@user_id", user_id));
                sql += "  and task.user_id=@user_id  ";
            }
            if (!String.IsNullOrEmpty(state))
            {
                sql += " and task.state=@state ";
                parameterList.Add(new SqlParameter("@state", state));
            }
            if (!String.IsNullOrEmpty(wfname))
            {
                sql += " and ins.insname =@wfname ";
                parameterList.Add(new SqlParameter("@wfname", wfname));
            }
            if (!String.IsNullOrEmpty(applyer))
            {
                sql += " and users.name like '%' + @applyer + '%'";
                parameterList.Add(new SqlParameter("@applyer", applyer));
            }
            if (!String.IsNullOrEmpty(stime))
            {
                stime = DateUtil.getBeginTimeBySecond(DateTime.Parse(stime));
                sql += " and task.starttime>=@stime ";
                parameterList.Add(new SqlParameter("@stime", stime));
            }
            if (!String.IsNullOrEmpty(etime))
            {
                etime = DateUtil.getEndTimeBySecond(DateTime.Parse(etime));
                sql += " and task.starttime<=@etime ";
                parameterList.Add(new SqlParameter("@etime", etime));
            }
            sql += " order by task.starttime desc ";
            var dt = DBExecuteUtil.querySqlTable(sql, parameterList.ToArray());
            return dt;
        }

        public static DataTable QueryTaskFinish(String user_id, String applyer, String wfname, String stime, String etime, String state)
        {
            string sql = " select task.task_id 任务编码,task.ptask_id 父级编码,task.uniqueid 实例标识,ins.insname 流程名称,  " +
                             " task.taskname 任务名称,task.state 任务状态,task.processresult 任务结果,starttime 开始时间,  " +
                             " endtime 完成时间,task.user_id 处理人编码,u1.user_name 处理人,d1.dept_name 部门1,task.fqrcode 发起人编码, " +
                             " u2.user_name 发起人,d2.dept_name 部门2,ins.ins_descn 备注  " +
                             " from wf_task task,wf_ins ins,jc_user u1,jc_user u2,jc_dept d1,jc_dept d2,jc_staff s1,jc_staff s2" +
                             " where task.user_id=u1.user_id and u1.staff_id=s1.staff_id and s1.dept_id=d1.dept_id " +
                             " and u2.staff_id=s2.staff_id and s2.dept_id=d2.dept_id and task.fqrcode=u2.user_id " +
                             " and task.uniqueid=ins.uniqueid and ins.result !='废弃' and task_id in (select tmp.id from ( " +
                             " select max(task_id) as id,uniqueid  from wf_Task  group by uniqueid,taskname,user_id) as tmp) ";
            List<SqlParameter> parameterList = new List<SqlParameter>();
            //if (uniqueids != null && uniqueids.Length > 0)
            //{
            //    sql += "  and task.uniqueid in (";
            //    for (int i = 0; i < uniqueids.Length; i++)
            //    {
            //        sql += "'" + uniqueids[i] + "',";
            //    }
            //    sql = sql.Substring(0, sql.Length - 1);//去除最后一个逗号
            //    sql += ") ";
            //}
            if (!string.IsNullOrEmpty(user_id))
            {
                parameterList.Add(new SqlParameter("@user_id", user_id));
                sql += "  and task.user_id=@user_id  ";
            }
            if (!String.IsNullOrEmpty(state))
            {
                sql += " and task.state=@state ";
                parameterList.Add(new SqlParameter("@state", state));
            }
            if (!String.IsNullOrEmpty(wfname))
            {
                sql += " and ins.insname =@wfname ";
                parameterList.Add(new SqlParameter("@wfname", wfname));
            }
            if (!String.IsNullOrEmpty(applyer))
            {
                sql += " and users.name like '%' + @applyer + '%'";
                parameterList.Add(new SqlParameter("@applyer", applyer));
            }
            if (!String.IsNullOrEmpty(stime))
            {
                stime = DateUtil.getBeginTimeBySecond(DateTime.Parse(stime));
                sql += " and task.starttime>=@stime ";
                parameterList.Add(new SqlParameter("@stime", stime));
            }
            if (!String.IsNullOrEmpty(etime))
            {
                etime = DateUtil.getEndTimeBySecond(DateTime.Parse(etime));
                sql += " and task.starttime<=@etime ";
                parameterList.Add(new SqlParameter("@etime", etime));
            }
            sql += " order by task.starttime desc ";
            var dt = DBExecuteUtil.querySqlTable(sql, parameterList.ToArray());
            return dt;
        }

        public static DataTable QueryTaskByWfType(string user_id, string state, string wftype_name)
        {
            List<SqlParameter> parameterList = new List<SqlParameter>();

            string sql = "select task.task_id 任务编码,task.ptask_id 父级编码,task.uniqueid 实例标识,task.taskname 任务名称,task.state 任务状态,starttime 开始时间,endtime 完成时间,users.user_name 发起人 " +
                             " from wf_task task,jc_user users,wf_ins ins,wf_wftype wftype,wf_wf wf " +
                             " where task.fqrcode=users.user_id and task.uniqueid=ins.uniqueid and wf.wf_id=ins.wf_id and wf.wftype_id=wftype.wftype_id ";
            if (!string.IsNullOrEmpty(user_id))
            {
                parameterList.Add(new SqlParameter("@user_id", user_id));
                sql += "  and task.user_id=@user_id  ";
            }
            if (!string.IsNullOrEmpty(state))
            {
                parameterList.Add(new SqlParameter("@state", state));
                sql += " and task.state=@state ";
            }
            if (!string.IsNullOrEmpty(wftype_name))
            {
                parameterList.Add(new SqlParameter("@wftype_name", wftype_name));
                sql += " and wftype_name=@wftype_name ";
            }
            sql += " order by task.starttime desc ";
            DataTable dt = DBExecuteUtil.querySqlTable(sql, parameterList.ToArray());

            return dt;
        }

        /// <summary>
        /// 查询包含该任务的所有工作流任务
        /// </summary>
        /// <param name="task_code">任务编码</param>
        /// <returns></returns>
        public static DataTable QueryTaskByUniqueId(string uniqueId)
        {
            if (string.IsNullOrEmpty(uniqueId)) return null;

            string sql = "select task.task_id 任务编码,task.ptask_id 父级编码,task.uniqueid 实例标识,task.taskname 任务名称,task.state 任务状态,task.processresult 处理结果,task.processtype 处理方式,starttime 开始时间,endtime 完成时间,task.user_id 处理人编码,users2.user_name 处理人,users.user_name 发起人" +
                              " from wf_task task,jc_user users,jc_user users2 " +
                              " where task.fqrcode=users.user_id and task.user_id=users2.user_id ";
            List<SqlParameter> parameterList = new List<SqlParameter>();
            if (!string.IsNullOrEmpty(uniqueId))
            {
                parameterList.Add(new SqlParameter("@uniqueId", uniqueId));
                sql += "  and task.uniqueId=@uniqueId  ";
            }
            sql += " order by task.starttime desc ";
            DataTable dt = DBExecuteUtil.querySqlTable(sql, parameterList.ToArray());
            return dt;
        }

        /// <summary>
        ///  查询该任务所有的审批结果
        /// </summary>
        /// <param name="uniqueId"></param>
        /// <returns></returns>
        public static DataTable QueryTaskSpjgByUniqueId(string uniqueId)
        {
            if (string.IsNullOrEmpty(uniqueId)) return null;

            string sql = " select users.user_name 审批人,depts.dept_name 部门,dutys.duty_name 职位,spqx.spqx_name 权限, " +
                             " processresult 审批结果,endtime 审批时间,task_clyj 审批意见 " +
                             " from wf_Task task,jc_user users,jc_dept depts,jc_duty dutys,wf_spqx spqx,jc_staff sta  " +
                             " where task.user_id=users.user_id and users.staff_id=sta.staff_id and sta.dept_id =depts.dept_id and sta.duty_id=dutys.duty_id" +
                             " and users.spqx_id=spqx.spqx_id and state='已处理' and ptask_id!=-1 and uniqueid=@uniqueId ";
            List<SqlParameter> parameterList = new List<SqlParameter>();
            parameterList.Add(new SqlParameter("@uniqueId", uniqueId));

            DataTable dt = DBExecuteUtil.querySqlTable(sql, parameterList.ToArray());
            return dt;
        }

        public static DataTable QueryTaskSpjgByTwo(string uniqueId, string task_id)
        {
            if (string.IsNullOrEmpty(uniqueId)) return null;

            string sql = " select users.user_name 审批人,depts.dept_name 部门,dutys.duty_name 职位,spqx.spqx_name 权限, " +
                             " processresult 审批结果,endtime 审批时间,task_clyj 审批意见 " +
                             " from wf_Task task,jc_user users,jc_dept depts,jc_duty dutys,wf_spqx spqx,jc_staff sta  " +
                             " where task.user_id=users.user_id and users.staff_id=sta.staff_id and sta.dept_id =depts.dept_id and sta.duty_id=dutys.duty_id" +
                             " and users.spqx_id=spqx.spqx_id and state='已处理' and ptask_id!=-1 and uniqueid=@uniqueId and task.task_id<=@task_id ";
            List<SqlParameter> parameterList = new List<SqlParameter>();
            parameterList.Add(new SqlParameter("@uniqueId", uniqueId));
            parameterList.Add(new SqlParameter("@task_id", task_id));

            DataTable dt = DBExecuteUtil.querySqlTable(sql, parameterList.ToArray());
            return dt;
        }

        public static DataTable QueryTaskByName(string uniqueId, String taskName)
        {
            if (string.IsNullOrEmpty(uniqueId)) return null;

            string sql = "select TOP 1 task.task_id 任务编码,task.ptask_id 父级编码,task.uniqueid 实例标识,task.taskname 任务名称,task.state 任务状态,task.processresult 处理结果,starttime 开始时间,endtime 完成时间,task.user_id 处理人编码,users.user_name 发起人, users.user_id 发起人编号,task.processtype 处理类型,task.processaddition 处理备注,task.task_clyj 处理意见 " +
                              " from wf_task task,jc_user users " +
                              " where task.fqrcode=users.user_id and task.state='已处理' ";
            List<SqlParameter> parameterList = new List<SqlParameter>();
            if (!string.IsNullOrEmpty(uniqueId))
            {
                parameterList.Add(new SqlParameter("@uniqueId", uniqueId));
                sql += "  and task.uniqueId=@uniqueId  ";
            }
            if (!String.IsNullOrEmpty(taskName))
            {
                parameterList.Add(new SqlParameter("@taskName", taskName));
                sql += " and task.taskname=@taskName";
            }
            sql += " order by task.task_id desc";//排序依据不能改掉
            var result = DBExecuteUtil.querySqlTable(sql, parameterList.ToArray());
            return result;
        }

        /// <summary>
        /// 查询所有委托人对应的当前任务
        /// </summary>
        /// <param name="deleg_wtrs"></param>
        /// <returns></returns>
        public static DataTable QueryByWtrIds(int[] deleg_wtrs)
        {

            string sql = "select task_id 任务编码 ,task.ptask_id 父级编码,task.uniqueid 实例标识,ins.insname 流程名称,task.taskname 任务名称,  " +
                             " task.state 任务状态,task.processresult 处理结果,starttime 开始时间,endtime 完成时间,  " +
                             " task.user_id 委托人编码,u1.user_name 委托人,de1.dept_name 部门1,du1.duty_name 职位1,fqrcode 发起人编码,u2.user_name 发起人,du2.duty_name 职位2,de2.dept_name 部门2 " +
                             " from wf_task task,jc_user u1,jc_user u2,wf_ins  ins ,jc_staff s1,jc_staff s2,jc_dept de1,jc_dept de2,jc_duty du1,jc_duty du2 " +
                             " where task.user_id=u1.user_id and task.fqrcode=u2.user_id and task.uniqueid=ins.uniqueid and task.state='未处理'  " +
                              "        and u1.staff_id=s1.staff_id and s1.dept_id=de1.dept_id and s1.duty_id=du1.duty_id " +
                              "        and u2.staff_id=s2.staff_id and s2.dept_id=de2.dept_id and s2.duty_id=du2.duty_id  ";

            string tmp = " and task.user_id in ('-1',";
            foreach (var item in deleg_wtrs)
            {
                if (string.IsNullOrEmpty(item.ToString())) continue;
                tmp += "'" + item.ToString() + "',";
            }
            tmp = tmp.Substring(0, tmp.Length - 1);//去掉最后一个逗号
            tmp += ")" + " order by task.starttime desc";
            sql += tmp;

            DataTable dt = DBExecuteUtil.querySqlTable(sql);
            return dt;
        }

        public static DataTable QueryTaskByRead(String userId, Int32 read)
        {
            //String sql = "SELECT [taskname],[task_id],[uniqueid],[ptask_id] FROM wf_task WHERE [user_id]=@userId AND [isread]=@read AND [ptask_id] != -1 AND [state]='未处理' ";
            string sql = " select task.task_id 任务编码,task.ptask_id 父级编码,task.uniqueid 实例标识,task.taskname 任务名称," +
                             " task.state 任务状态,starttime 开始时间,endtime 完成时间,users.user_name 发起人,insname 流程名称,createdate 申请时间 " +
                             " from wf_task task,jc_user users,wf_ins ins " +
                             " where task.fqrcode=users.user_id and task.uniqueid=ins.uniqueid and task.user_id=@userId  and task.isread=@read and ptask_id != -1 AND task.state='未处理' ";
            List<SqlParameter> parameterList = new List<SqlParameter>();
            parameterList.Add(new SqlParameter("@userId", userId));
            parameterList.Add(new SqlParameter("@read", read));
            return DBExecuteUtil.querySqlTable(sql, parameterList.ToArray());
        }

        public static void ConfirmUnreadTask(String taskId)
        {
            String sql = "UPDATE wf_task SET [isread]=1 WHERE [task_id]=@taskId";
            List<SqlParameter> parameterList = new List<SqlParameter>();
            parameterList.Add(new SqlParameter("@taskId", taskId));
            DBExecuteUtil.executeSqlWithPar(sql, parameterList.ToArray());
        }


    }
}
